<template lang="html">
  <div class="main">
    <div class="main-group">
      <div class="main-body">
        <div class="title">
          我是标题
        </div>
        <div class="body">
          <div id="test_chart" class="chart">

          </div>
        </div>
      </div>
      <div class="main-body">
        <div class="title">
          我是标题
        </div>
        <div class="body">
          <div id="test_chart2" class="chart">
          </div>
          <div class="chart-title" id="title2" v-show="show">
            南丁格尔玫瑰图
          </div>
        </div>
      </div>
    </div>
    <div class="main-menu">
      <div class="menu">
        <span @click="back">上一个</span>
        <span @click="back">返回</span>
        <span @click="back">下一个</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      show: true
    };
  },
  methods: {
    back () {
      this.$router.go(-1);
    },
    draw2 () {
      let chart = this.$echarts.init(document.getElementById('test_chart2'));
      let option = {
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b}: {c} ({d}%)'
        },
        legend: {
          orient: 'vertical',
          x: 'left',
          data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
        },
        color: ['#2FE0B6', '#01C853', '#FFD741', '#7C4DFF', '#3FC4FF'],
        series: [
          {
            name: '访问来源',
            type: 'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
              normal: {
                show: false,
                position: 'center'
              },
              emphasis: {
                show: true,
                textStyle: {
                  fontSize: '30',
                  fontWeight: 'bold'
                }
              }
            },
            labelLine: {
              normal: {
                show: false
              }
            },
            data: [
              {value: 335, name: '直接访问'},
              {value: 310, name: '邮件营销'},
              {value: 234, name: '联盟广告'},
              {value: 135, name: '视频广告'},
              {value: 1548, name: '搜索引擎'}
            ]
          }
        ]
      };
      chart.setOption(option);
      chart.on('mouseover', () => {
        this.show = false;
      });
      chart.on('mouseout', () => {
        this.show = true;
      });
    },
    draw () {
      let chart = this.$echarts.init(document.getElementById('test_chart'));
      let option = {
        title: {
          text: '南丁格尔玫瑰图',
          subtext: '纯属虚构',
          x: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          x: 'center',
          y: 'bottom',
          data: ['rose1', 'rose2', 'rose3', 'rose4', 'rose5']
        },
        color: ['#FF4181', '#01C853', '#FFD741', '#7C4DFF', '#3FC4FF'],
        toolbox: {
          show: true,
          feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {
              show: true,
              type: ['pie', 'funnel']
            },
            restore: {show: true},
            saveAsImage: {show: true}
          }
        },
        calculable: true,
        series: [
          {
            name: '面积模式',
            type: 'pie',
            radius: [30, 110],
            center: ['50%', '50%'],
            roseType: 'area',
            data: [
              {value: 10, name: 'rose1'},
              {value: 5, name: 'rose2'},
              {value: 15, name: 'rose3'},
              {value: 25, name: 'rose4'},
              {value: 20, name: 'rose5'}
            ]
          }
        ]
      };
      chart.setOption(option);
    }
  },
  mounted () {
    this.draw();
    this.draw2();
  }
};
</script>

<style lang="css" scoped>
.main {
  background-image: url('../../assets/bg_all_2.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  vertical-align: middle;
  justify-content: center;
  align-items: center;
  text-align: center;
  .main-group {
    width: 70%;
    height: 70%;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    .main-body {
      flex: 1;
      margin-left: 20px;
      box-shadow: 2px 6px 12px 2px rgba(0,0,0,.8);
      border-radius: 4px;
      border: 3px solid #ebeef5;
      background-color: rgba(255,255,255,.95);
      overflow: hidden;
      color: #303133;
      transition: .3s;
      .title {
        position: relative;
        height: 60px;
        line-height: 60px;
        text-align: left;
        margin-left: 20px;
        margin-right: 20px;
      }
      .title::after {
        content: '';
        position: absolute;
        width: 100%;
        height: 3px;
        top: 100%;
        left: 0px;
        overflow: hidden;
        border-top: 1px solid  rgba(150,150,150,.5);
        border-bottom: 1px solid  rgba(255,255,255,1);
        background-color: #eee;
      }
      .body {
        padding: 10px;
        height: 100%;
        width: 100%;
        position: relative;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        .chart {
          width: 100%;
          height: 100%;
        }
        .chart-title {
          position: absolute;
          top: 50%;
          margin-top: -15px;
          height: 30px;
          width: 100%;
          margin-left: -10px;
          text-align: center;
          font-size: 25px;
          color: #999;
          font-weight: 800;
        }
      }
    }
    .main-body:first-child {
      margin-left: 0px;
    }
  }
  .main-menu {
    width: 70%;
    height: 50px;
    margin-top: 15px;
    position: relative;
    .menu {
      font-size: 20px;
      font-family: '微软雅黑';
      color: rgba(255,255,255,0.5);
      display: flex;
      flex-direction: row;
      vertical-align: middle;
      justify-content: center;
      align-items: center;
      text-align: center;
      height: 100%;
      margin-left: 30%;
      margin-right: 30%;
      span {
        display: block;
        flex: 1;
        cursor: pointer;
      }
      span:hover {
        transition: all .3s;
        font-size: 26px;
      }
    }
    .menu::after {
      content: '';
      position: absolute;
      width: 50%;
      height: 20px;
      top: 100%;
      overflow: hidden;
      background-size:100% 100%;
      background-image: url('../../assets/pic_back_tips.png');
    }
  }
}
</style>
